{extend name="layout/detail" /}
{block name="content"}
<div class="td-content-wrap p20">
    <div class="td-content-header">
        <h1 class="main-title">报名管理</h1>
    </div>
    <hr>
    <div class="panel no-border">
        <form id="form_search" class="flex rcs" method="post" action="">
            <input type="hidden" name="aid" value="{$aid}" />
            <div class="filter-item-view flex rcs">
                <span class="layui-input-title mw-5">用户姓名：</span>
                <input type="text" id="username" name="username" class="layui-input">
            </div>
            <div class="filter-item-view flex rcs ml-2">
                <span class="layui-input-title mw-5">报名时间：</span>
                <input class="layui-input input-date-range mw-15" name="create_time_range" readonly="readonly" />
            </div>
            <div class="btn-item ml-5" onclick="form_search();">
                <span class="layui-btn">搜索</span>
            </div>
            <div class="btn-item ml-2" onclick="export_to_excel();">
                <span class="layui-btn">导出</span>
            </div>
        </form>
    </div>
    <hr>
    <table id="data_table" lay-filter="data_table"></table>
</div>
{/block}

{block name="script"}
<script>
    layui.use(['data_table'], function () {
        let $ = layui.jquery;
        let data_table = layui.data_table;

        // 记录返回地址
        set_return_url();

        // 页面用到方法
        let fn = {
            export_to_excel: function () {
                $form_search = $("#form_search");
                $form_search.attr('action', "{:url('export_to_excel')}");
                $form_search.attr('target', '_blank');
                $form_search.submit();
            },
            add: function (data) {
                window.open('{:url("add")}', '_self');
            },
            read: function (data) {
                window.open('{:url("read")}?id=' + data.id, '_self');
            },
            edit: function (data) {
                window.open('{:url("edit")}?id=' + data.id, '_self');
            },
            is_top: function (data) {
                popup_open('{:url("is_top")}?id=' + data.id, 630, 350);
            },
            tag: function (data) {
                popup_open('{:url("tag")}?id=' + data.id, 630, 350);
            },
            article_category: function () {
                window.open('{:url("article_category/index")}', '_self');
            },
            del: function (data) {
                layer.msg('确定要删除吗?', {
                    time: 0,
                    btn: ['确定', '取消'],
                    yes: function (index) {
                        var vars = 'id=' + data.id;
                        $.get("{:url('del')}", vars, function (res) {
                            if (res.code) {
                                layer.msg(res.msg, {
                                    time: 1200
                                }, function () {
                                    location.reload(true);
                                });
                            } else {
                                layer.msg(res.msg);
                            }
                        });
                    },
                    no: function (index) {
                        layer.close(index);
                    }
                });
            },
        };

        win_exp(fn);

        let cols0 = [
            {
                width: 80,
                title: '报名ID',
                field: 'id',
                align: 'center',
            },
            {
                field: 'create_time',
                title: '报名时间',
                align: 'center',
            },
            {
                field: 'username',
                title: '姓名',
                align: 'center',
            },
            {
                field: 'id_card_no',
                title: '身份证号',
                align: 'center',
            },
            {
                field: 'mobile',
                title: '手机号',
                align: 'center',
            },
            {
                field: 'email',
                title: '邮箱',
                align: 'center',
            },
        ];
        let cols1 = [
            {
                field: 'graduated_school',
                title: '毕业院校',
                align: 'center',
            },
            {
                field: 'education',
                title: '学历',
                align: 'center',
            },
            {
                field: 'graduation_year',
                title: '毕业年度',
                align: 'center',
            },
            {
                field: 'industry_type',
                title: '意向行业',
                align: 'center',
            },
            {
                field: 'job_type',
                title: '求职岗位',
                align: 'center',
            },
            {
                field: 'expected_salary',
                title: '期望薪资',
                align: 'center',
            },
        ];
        let cols2 = [
            {
                field: 'school_name',
                title: '学校/公司',
                align: 'center',
            },
            {
                field: 'purpose',
                title: '参会目的',
                align: 'center',
            },
        ];

        var aid = '{$aid}';

        let cols3 = aid == 1 ? cols0.concat(cols1) : cols0.concat(cols2);

        data_table.config.cols = [cols3];
        data_table.render();

    });
</script>
{/block}